#!/bin/bash

# map
# 0 student
# 1 riviera
# 2 mikrus
# 3 ustronie
# 4 akademik
# 5 muszelka
# 6 tulipan
# 7 babilon
# 8 zaczek
# 9
# 10
# 11 pineska
# 12 bratniak



#mysql -u serwus --password=serwus123 qsearch -e "insert into hosts values ('$1.$2.$3')"

TABLE="hosts2"

mysql -u serwus --password=serwus123 qsearch -e "create table if not exists $TABLE  (ip varchar(16), scanned datetime, pinged dateitime, active bool );" # create if not exists
mysql -u serwus --password=serwus123 qsearch -e "truncate table $TABLE" # clear table
for i in $(seq 0 12); do
	echo 10.$i.0.0
	(
	for j in $(seq 1 12); do	
		for ((k=0;k<=255;++k)); do
                        ( host 10.$i.$j.$k >/dev/null && 
				( 
					echo 10.$i.$j.$k here here here
					mysql -u serwus --password=serwus123 qsearch -e "insert into $TABLE values ('$i.$j.$k', '1000-01-01 00:00:00', '1000-01-01 00:00:00', TRUE)"
				) 
			) &
		done
	done
	
	) & 
done

